package com.example.cms.Schedules;


import java.time.LocalDate;

public class Schedule {
    private Integer scheduleId;
    private Integer doctorId;
    private String doctorName;
    private String departmentName;
    private LocalDate scheduleDate;
    private String timeSlot;
    private Integer totalSlots;
    private Integer bookedSlots;
    private Integer availableSlots;
    private String status;
    private String roomNumber;
    private Double fee;

    // 构造器
    public Schedule() {
        this.totalSlots = 20;
        this.bookedSlots = 0;
        this.status = "AVAILABLE";
    }

    public Schedule(Integer doctorId, LocalDate scheduleDate, String timeSlot) {
        this();
        this.doctorId = doctorId;
        this.scheduleDate = scheduleDate;
        this.timeSlot = timeSlot;
        this.availableSlots = this.totalSlots - this.bookedSlots;
    }

    // Getter 和 Setter 方法
    public Integer getScheduleId() {
        return scheduleId;
    }

    public void setScheduleId(Integer scheduleId) {
        this.scheduleId = scheduleId;
    }

    public Integer getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(Integer doctorId) {
        this.doctorId = doctorId;
    }

    public String getDoctorName() {
        return doctorName;
    }

    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public LocalDate getScheduleDate() {
        return scheduleDate;
    }

    public void setScheduleDate(LocalDate scheduleDate) {
        this.scheduleDate = scheduleDate;
    }

    public String getTimeSlot() {
        return timeSlot;
    }

    public void setTimeSlot(String timeSlot) {
        this.timeSlot = timeSlot;
    }

    public Integer getTotalSlots() {
        return totalSlots;
    }

    public void setTotalSlots(Integer totalSlots) {
        this.totalSlots = totalSlots;
        updateAvailableSlots();
    }

    public Integer getBookedSlots() {
        return bookedSlots;
    }

    public void setBookedSlots(Integer bookedSlots) {
        this.bookedSlots = bookedSlots;
        updateAvailableSlots();
    }

    public Integer getAvailableSlots() {
        return availableSlots;
    }

    public void setAvailableSlots(Integer availableSlots) {
        this.availableSlots = availableSlots;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(String roomNumber) {
        this.roomNumber = roomNumber;
    }

    public Double getFee() {
        return fee;
    }

    public void setFee(Double fee) {
        this.fee = fee;
    }

    private void updateAvailableSlots() {
        this.availableSlots = this.totalSlots - this.bookedSlots;
        if (this.availableSlots <= 0) {
            this.status = "FULL";
        }
    }

    @Override
    public String toString() {
        return "Schedule{" +
                "scheduleId=" + scheduleId +
                ", doctorId=" + doctorId +
                ", scheduleDate=" + scheduleDate +
                ", timeSlot='" + timeSlot + '\'' +
                ", totalSlots=" + totalSlots +
                ", bookedSlots=" + bookedSlots +
                ", availableSlots=" + availableSlots +
                ", status='" + status + '\'' +
                '}';
    }
}
